﻿using System;
using System.IO;

using MbUnit.Framework;

namespace Abstract2ion.Tests
{
	public class FileSystemWrapperTestFixture : FileSystemTestFixtureBase
	{
		private FileSystemWrapper _fileSystemWrapper;

		[SetUp]
		public void Setup()
		{
			_fileSystemWrapper = new FileSystemWrapper();
		}

		[Test]
		public void ShouldReturnCurrentDirectory()
		{
			Assert.AreEqual(Environment.CurrentDirectory, _fileSystemWrapper.CurrentDirectory.FullName);
		}

		[Test]
		public void ShouldFindExistingDirectory()
		{
			var directoryInfo = _fileSystemWrapper.FindDirectory(FirstDirectoryPath);

			Assert.AreEqual(FirstDirectoryPath, directoryInfo.FullName);
		}

		[Test]
		public void ShouldNotFindNonexistentDirectory()
		{
			Assert.Throws<DirectoryNotFoundException>(() => _fileSystemWrapper.FindDirectory(Path.Combine(BasePath, "Unknonwn")));
		}

		[Test]
		public void ShouldFindExistingFile()
		{
			var fileInfo = _fileSystemWrapper.FindFile(FirstFilePath);

			Assert.AreEqual(FirstFilePath, fileInfo.FullName);
		}

		[Test]
		public void ShouldNotFindNonexistentFile()
		{
			Assert.Throws<FileNotFoundException>(() => _fileSystemWrapper.FindFile(InvalidFilePath));
		}
	}
}